<template>
	<view class="box" v-if="tuiData">
		<v-tuik :price="tuiData" :yuanyList="yuanyList" @getReson="getReson"></v-tuik>
    <view class="btn" @click="refund()" v-if="pup_type != 4">确定</view>
	</view>
</template>

<script>
	// 价格 = 背包单价 * 数量 * 天数 + 行李箱单价 * 数量 * 天数
	// 价格 = 天数 * (背包单价 * 数量 + 行李箱单价 * 数量)、
  import tuik from '@/components/tuik.vue';
	export default {
    components: {
      'v-tuik':tuik,
    },
		data() {
			return {
				id: '',
				
        tuiData:null,
        refund_reason:'',
        yuanyList:{}
			}
		},
		onLoad(e) {
      this.id = e.id;
      this.$http.get(this.$api.refundReasonAPi, {}).then(res=>{
        this.yuanyList = res.data;
      })
			getApp().get_loading();
			this.getOrdersDetail();
      
		},
		onShow() {
			
			
		},
		onLaunch() {
      
		},
		methods: {
      
      refund(){
        if(this.refund_reason === '') return getApp().get_msg('请选择退款原因');
        uni.showModal({
          title:"提示",
          content:"确定要取消该订单吗？",
          success: (e) => {
            if(e.confirm){
              uni.showLoading()
              this.get_refund()
            }
          }
        })
      },
      get_refund() {
        console.log('this.refund_reason===>',this.refund_reason)
      	this.$http.get(this.$api.refundApi, {
      		order_id: this.id,
          refund_reason:this.refund_reason
      	}).then(res => {
          uni.hideLoading()
      		getApp().get_msg('退款成功，金额稍后，请耐心等待');
      		getApp().get_back();
          this.tuiShow = false;
      		// uni.setStorageSync('orderList', true);
      	}).catch(()=>{
          uni.hideLoading()
        })
      },
      getReson(e){
        this.refund_reason = e;
      },
      
      getOrdersDetail() {
      	this.$http.post(this.$api.refundDescApi,{order_id: this.id}).then(tui=>{
          console.log('tui.data===>',tui.data)
      	  this.tuiData = tui.data;
      	  if(tui.data.is_commission){
      	    uni.showModal({
      	      title:"提示",
      	      content:tui.data.commission_tip,
              showCancel:false,
              confirmText:'知道了',
      	      success: (e) => {
      	        
      	      }
      	    })
      	  }
      	})
      },
     
		}
	}
</script>

<style lang="less">
	.box{padding: 20rpx 30rpx; box-sizing: border-box;}
  .btn{background-color: #FF6A00; color: #fff; display: flex; align-items: center; justify-content: center; border-radius: 6rpx; margin-top: 20rpx; height: 70rpx; font-size: 28rpx; margin-top: 40rpx;}
</style>
